

function deepClone(obj){
    if(typeof obj!=='object')return obj
    let newObj=Array.isArray(obj)?[]:{}

    for(let key in obj){
        if(obj.hasOwnProperty(key)){
            if(typeof obj[key] ==='object'){
                newObj[key]=deepClone(obj[key])
            }else{
                newObj[key]=obj[key]
            }
        }
    }
    return newObj
}
let arr=[1,2,3]
let oo={ 'dd': 1, 's': 2, 'vv': 3 }
console.log(deepClone(oo));
const target = {
    field1: 1,
    field2: undefined,
    field3: {
        child: 'child'
        
    },
    field4: [2, 3, 8]
};
 target.target=target
//  target.field4.push(target.field4)
 console.log(deepClone(target));

console.log(target);

console.log(target.field4[3]);

